home *** CD-ROM | disk | FTP | other *** search
/ CU Amiga Super CD-ROM 18 / CU Amiga Magazine's Super CD-ROM 18 (1997)(EMAP Images)(GB)[!][issue 1998-01].iso / CUCD / Programming / AmigaE / Src / OOmodules / list / execlist.e < prev    next >
Encoding:
Text File  |  1996-07-20  |  3.2 KB  |  177 lines

  1. OPT MODULE
  2.  
  3. MODULE  'oomodules/object',
  4.  
  5.         'tools/constructors',
  6.  
  7.         'exec/lists',
  8.         'exec/nodes'
  9.  
  10. EXPORT OBJECT execlist OF object
  11. /****** object/execlist ******************************
  12.  
  13.     NAME
  14.         execlist of object -- List as used in the exec.library
  15.  
  16.     PURPOSE
  17.         Just a quick and small implementation of exec's list. Only useable
  18.         for converting from an elist (for listviews etc.)
  19.  
  20.     ATTRIBUTES
  21.         list:PTR TO lh -- exec's list header
  22.  
  23.         len:LONG -- number of nodes in the list
  24.  
  25.     SEE ALSO
  26.         object, exec
  27.  
  28. ********/
  29.   list:PTR TO lh,
  30.   len
  31. ENDOBJECT
  32.  
  33. PROC init() OF execlist IS EMPTY
  34. /****** execlist/init ******************************
  35.  
  36.     NAME
  37.         init() of execlist -- Initialization of the object.
  38.  
  39.     SYNOPSIS
  40.         execlist.init()
  41.  
  42.     FUNCTION
  43.         Empty by now.
  44.  
  45.     SEE ALSO
  46.         execlist
  47.  
  48. ********/
  49.  
  50. PROC select(optionlist, index) OF execlist
  51. /****** execlist/select ******************************
  52.  
  53.     NAME
  54.         select() of execlist -- Selection of action.
  55.  
  56.     SYNOPSIS
  57.         execlist.select(LONG, LONG)
  58.  
  59.         execlist.select(optionlist, index)
  60.  
  61.     FUNCTION
  62.         Recognized tags are:
  63.             "list" -- take items as node names. See fromList().
  64.     INPUTS
  65.         optionlist:LONG -- list of options
  66.  
  67.         index:LONG -- index of option list
  68.  
  69.     SEE ALSO
  70.         execlist, fromList()
  71.  
  72. ********/
  73. DEF item
  74.  
  75.   item:=ListItem(optionlist,index)
  76.  
  77.   SELECT item
  78.  
  79.     CASE "list"
  80.  
  81.       INC index
  82.       self.fromList(ListItem(optionlist,index))
  83.  
  84.   ENDSELECT
  85.  
  86. ENDPROC index
  87.  
  88. PROC fromList(list:PTR TO LONG) OF execlist
  89. /****** execlist/fromList ******************************
  90.  
  91.     NAME
  92.         fromList() of execlist -- Take items of elist as node names.
  93.  
  94.     SYNOPSIS
  95.         execlist.fromList(LONG)
  96.  
  97.         execlist.fromList(list)
  98.  
  99.     FUNCTION
  100.         Creates a list. The items of the passed elist are taken as names of
  101.         the nodes. Therefore you may free the elist but not the items.
  102.  
  103.     INPUTS
  104.         list:LONG -- E list of strings.
  105.  
  106.     SEE ALSO
  107.         execlist
  108.  
  109. ********/
  110. DEF execlist:PTR TO lh,
  111.     execnode:PTR TO ln,
  112.     nextNode:PTR TO ln,
  113.     str,
  114.     item,
  115.     index
  116.  
  117.   IF list=NIL THEN RETURN
  118.  
  119.   self.list := newlist()
  120.  
  121.   FOR index := 0 TO ListLen(list)-1
  122.  
  123.     execnode := newnode(NIL, ListItem(list,index))
  124.     AddTail(self.list,execnode)
  125.  
  126.   ENDFOR
  127.  
  128.   self.len := ListLen(list)
  129.  
  130. ENDPROC
  131.  
  132. PROC end() OF execlist
  133. /****** execlist/end ******************************
  134.  
  135.     NAME
  136.         end() of execlist -- Global destructor.
  137.  
  138.     SYNOPSIS
  139.         execlist.end()
  140.  
  141.     FUNCTION
  142.         Disposes all nodes and the list. If the nodes have names you have to
  143.         dispose them.
  144.  
  145.     SEE ALSO
  146.         execlist
  147.  
  148. ********/
  149. DEF execnode:PTR TO ln,
  150.     index,
  151.     nextNode:PTR TO ln
  152.  
  153.   execnode := self.list.head
  154.  
  155.   WriteF('ending exec list with \d nodes.\n', self.len)
  156.  
  157.   FOR index:=1 TO self.len
  158.  
  159.     nextNode := execnode.succ
  160.     WriteF('ending node at \d, next node is \d.\n', execnode, nextNode)
  161.     Dispose(execnode)
  162.     execnode := nextNode
  163.  
  164.   ENDFOR
  165.  
  166.   WriteF('ending list header at \d.\n')
  167.   Dispose(self.list)
  168.  
  169.   WriteF('all resources of object freed, returning.\n')
  170.  
  171. ENDPROC
  172.  
  173. /*EE folds
  174. -1
  175. 10 21 29 35 32 41 
  176. EE folds*/
  177.